/**
 * Created by Administrator on 2016/7/28 0028.
 */
$(function () {
    getTeacher();
    $("#set-enter").click(function () {
        var reg=/\s*[0-9a-zA-Z\u4e00-\u9fa5]+$/;
        if(!reg.test($("#name input").val())){
            alert("请输入正确的项目名！");
            return;
        }
        if($("#introduction textarea").val()==""){
            alert("请填写项目简介！")
            return;
        }
        var dateReport = {};
        dateReport.flag="add";
        dateReport.name=$("#name input").val();
        dateReport.teacherID=$("#teacher").val();
        dateReport.introduction=$("#introduction textarea").val();
        alert($("#introduction textarea").val());
        var url="/TaskCollection/project";
        $.post(url,dateReport,function (result) {
            if(result.msg){
                alert("申报成功，等待批准！");
            }else {
                alert("请求失败，请重试！");
            }
        },"json");
    });
    $("#set-back").click(function () {
        self.location='/TaskCollection/student/homepage.jsp';
    });
});
function getTeacher() {
    var url = "/TaskCollection/teacherService";
    var dataTea = {};
    dataTea.flag="getAll";
    var option="";
    $.post(url,dataTea,function (result) {
        if(result.getAll==null){
            
        }else {
            for(var i = 0;i<result.getAll.length;i++){
                var teacherName = result.getAll[i].teacher_name;
                if(teacherName!=null){
                    option+="<option value='"+result.getAll[i].teacher_id+"'>"+result.getAll[i].teacher_name+"</option>";
                }
            }
            $("#teacher").html(option);
        }
    },"json");
}
